package com.huawei.appgallery.wishlist.widget;

import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Path;
import android.util.AttributeSet;
import com.huawei.appgallery.foundation.ui.framework.widget.MaskImageView;
import o.dce.h;
import o.dch;
import o.dky.a;

public class WishRoundImageView extends MaskImageView {
    private boolean ʻ;
    private int ʽ;
    int ˊ;
    int ˋ;
    int ˏ;

    public WishRoundImageView(Context context) {
        this(context, null);
    }

    public WishRoundImageView(Context context, AttributeSet attributeSet) {
        this(context, attributeSet, 0);
    }

    public WishRoundImageView(Context context, AttributeSet attributeSet, int i) {
        int i2 = 0;
        super(context, attributeSet, i);
        this.ʻ = true;
        if (attributeSet != null) {
            try {
                int dimensionPixelSize;
                TypedArray obtainStyledAttributes = context.obtainStyledAttributes(attributeSet, h.ᐝʽ, i, 0);
                if (obtainStyledAttributes.hasValue(h.ॱﾟ)) {
                    i2 = obtainStyledAttributes.getDimensionPixelSize(h.ॱﾟ, 0);
                }
                this.ʽ = obtainStyledAttributes.hasValue(h.ᐧॱ) ? obtainStyledAttributes.getDimensionPixelSize(h.ᐧॱ, i2) : i2;
                if (obtainStyledAttributes.hasValue(h.ᴵ)) {
                    dimensionPixelSize = obtainStyledAttributes.getDimensionPixelSize(h.ᴵ, i2);
                } else {
                    dimensionPixelSize = i2;
                }
                this.ˊ = dimensionPixelSize;
                if (obtainStyledAttributes.hasValue(h.ᵢ)) {
                    dimensionPixelSize = obtainStyledAttributes.getDimensionPixelSize(h.ᵢ, i2);
                } else {
                    dimensionPixelSize = i2;
                }
                this.ˏ = dimensionPixelSize;
                if (obtainStyledAttributes.hasValue(h.ᵔ)) {
                    i2 = obtainStyledAttributes.getDimensionPixelSize(h.ᵔ, i2);
                }
                this.ˋ = i2;
                this.ʻ = obtainStyledAttributes.hasValue(h.ᵎ) ? obtainStyledAttributes.getBoolean(h.ᵎ, this.ʻ) : this.ʻ;
                obtainStyledAttributes.recycle();
            } catch (RuntimeException e) {
                dch.ˎ.ˊ("RoundImageView", "RoundImageView init(AttributeSet attrs) " + e.toString());
            }
        }
    }

    public void setRadius(int i) {
        this.ˋ = i;
        this.ˏ = i;
        this.ˊ = i;
        this.ʽ = i;
        postInvalidate();
    }

    public void ˎ() {
        if (this.ʻ) {
            this.ॱ = getResources().getDrawable(a.ˋˊ);
        } else {
            this.ॱ = null;
        }
    }

    protected void onDraw(Canvas canvas) {
        ˏ(canvas, getWidth(), getHeight());
        ˎ(canvas);
        super.onDraw(canvas);
    }

    protected void ˎ(Canvas canvas) {
    }

    public void ˏ(Canvas canvas, int i, int i2) {
        if (Math.min(i, i2) > Math.max(Math.max(this.ʽ, this.ˏ), Math.max(this.ˊ, this.ˋ))) {
            Path path = new Path();
            path.moveTo((float) this.ʽ, 0.0f);
            path.lineTo((float) (i - this.ˊ), 0.0f);
            path.quadTo((float) i, 0.0f, (float) i, (float) this.ˊ);
            path.lineTo((float) i, (float) (i2 - this.ˋ));
            path.quadTo((float) i, (float) i2, (float) (i - this.ˋ), (float) i2);
            path.lineTo((float) this.ˏ, (float) i2);
            path.quadTo(0.0f, (float) i2, 0.0f, (float) (i2 - this.ˏ));
            path.lineTo(0.0f, (float) this.ʽ);
            path.quadTo(0.0f, 0.0f, (float) this.ʽ, 0.0f);
            canvas.clipPath(path);
        }
    }
}
